//
//  MsgMap.swift
//  Aiwei
//
//  Created by zhu xietong on 2018/1/25.
//  Copyright © 2018年 zhu xietong. All rights reserved.
//

import Foundation

public class MsgMap{
    
    public static let data_db = DB.sqlite(db_name: "sysnum.db")
    public static func save(type:EeMsgType,msgID:String,ID:String){
        let sql = "insert into map(msg_type,msg_id,obj_id) values('\(type.rawValue)','\(msgID)','\(ID)')"
        data_db.exec(sql: sql)
    }
    
    public static func getMsgID(type:EeMsgType,objID:String)->String{
        let sql = "select * from map where msg_type = '\(type.rawValue)' and obj_id = '\(objID)' order by id DESC"
        let list = data_db.query(sql: sql)
        if list.count > 0{
            return list[0].mutable_dictionary["msg_id",""]
        }
        
        return ""
    }
    
}

